set(MODULE_NAME tetgenlib)
set(ENABLE_LIBRARY 1)

set(MODULE_SOURCES 
    ../tetgen/tetgen.h 
    ../tetgen/tetgen.cxx 
    ../tetgen/predicates.cxx 
    ../tetgenext.cxx
    ../tetgenext.h
    ../tgdefines.h
    ../base64.h
)

set(MODULE_SOURCES ${MODULE_SOURCES}
   ../json/jsoncpp.cpp
)

if(MSVC)
  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

include_directories(../)
include_directories(../tetgen)

if(ENABLE_LIBRARY)
  add_definitions(-DTETLIBRARY)
  add_library(${MODULE_NAME} STATIC ${MODULE_SOURCES} )
  set_static_lib()
else()
  add_executable(${MODULE_NAME} ${MODULE_SOURCES})
endif()

if(MSVC)
  set_target_properties(${MODULE_NAME} PROPERTIES COMPILE_FLAGS "/bigobj")
else()
  set_target_properties(${MODULE_NAME} PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()

list(APPEND MESHER_LIBS_REQUIRED jsoncpp)

search_append_libs()
target_link_libraries(${MODULE_NAME} ${EXTERNAL_LIBRARIES} debug "${EXTERNAL_LIBRARIES_DEBUG}" optimized  "${EXTERNAL_LIBRARIES_OPT}")